//package com.poi.java;
//
//
//import com.alibaba.fastjson.JSON;
//import com.fasterxml.jackson.databind.JsonNode;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.fasterxml.jackson.databind.node.ObjectNode;
//import org.json.JSONObject;
//
//import java.io.IOException;
//
///**
// * @Description:
// * @Auther:zs
// * @Date: 2023/6/8 8:49
// */
//public class GeoJsonUtils {
//    public static void main(String[] args) throws Exception {
////        String geoJsonString = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[120.635,31.3696]}},{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[121.438,31.2242]}}]}";
////        String geoJsonString = "{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[-38.7283,140.5269],[-30.2449,126.3724],[-2.8321,157.069],[-813.1207,-162.875],[-70.1088,143.8024],[-49.3244,87.5957],[-28.2541,87.2148],[-28.6471,103.0533],[-38.7283,140.5269]]]]},"properties":{"Id":0},"id":"TestB.1"}
////{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[18.0598,68.1509],[31.6722,86.2173],[26.6619,127.3885],[8.6556,106.9449],[-2.5337,101.9771],[18.0598,68.1509]]]]},"properties":{"Id":0},"id":"TestB.2"}";
////        String result = GeoJsonUtils.reverseCoordinates(geoJsonString);
//        String geoJsonString = "{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[-38.7283,140.5269],[-30.2449,126.3724],[-2.8321,157.069],[-813.1207,-162.875],[-70.1088,143.8024],[-49.3244,87.5957],[-28.2541,87.2148],[-28.6471,103.0533],[-38.7283,140.5269]]]]},\"properties\":{\"Id\":0},\"id\":\"TestB.1\"}\n" +
//                "{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPolygon\",\"coordinates\":[[[[18.0598,68.1509],[31.6722,86.2173],[26.6619,127.3885],[8.6556,106.9449],[-2.5337,101.9771],[18.0598,68.1509]]]]},\"properties\":{\"Id\":0},\"id\":\"TestB.2\"}";
//        /*
//        * {"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":
//        * [[[[-38.7283,140.5269],[-30.2449,126.3724],[-2.8321,157.069],[-813.1207,-162.875],[-70.1088,143.8024],[-49.3244,87.5957],[-28.2541,87.2148],[-28.6471,103.0533],[-38.7283,140.5269]]]]},"properties":{"Id":0},"id":"TestB.1"}
//{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[18.0598,68.1509],[31.6722,86.2173],[26.6619,127.3885],[8.6556,106.9449],[-2.5337,101.9771],[18.0598,68.1509]]]]},"properties":{"Id":0},"id":"TestB.2"}*/
//        JSONObject jsonObject = new JSONObject(geoJsonString);
//        String geometry = jsonObject.get("geometry").toString();
//        String[] split = geometry.split("\\[" + "\\[" + "\\[" + "\\[");
//        String s = split[1];
//        System.out.println(s);
////        net.minidev.json.JSONObject jsonObject1 = new net.minidev.json.JSONObject();
//
//
////        System.out.println(result);
//    }
//
//    public static String reverseCoordinates(String geoJsonString) throws Exception {
//        ObjectMapper objectMapper = new ObjectMapper();
//        JsonNode rootNode = objectMapper.readTree(geoJsonString);
//        JsonNode featuresNode = rootNode.path("features");
//        for (JsonNode featureNode : featuresNode) {
//            JsonNode geometryNode = featureNode.path("geometry");
//            JsonNode coordinatesNode = geometryNode.path("coordinates");
//            if (coordinatesNode.isArray()) {
//                reverseCoordinates(coordinatesNode);
//            }
//        }
//
//
//        return objectMapper.writeValueAsString(rootNode);
//    }
//
//    private static void reverseCoordinates(JsonNode node) throws IOException {
//        if (node.isArray()) {
//            for (JsonNode elementNode : node) {
//                reverseCoordinates(elementNode);
//            }
//        } else {
//            double x = node.traverse().getValueAsDouble(0);
//            double y = node.traverse().getValueAsDouble(1);
////            double y = node.get(1).asDouble();
//            ((ObjectNode) node).put("1", y);
//            ((ObjectNode) node).put("0", x);
//        }
//    }
//}
//
